package com.gim.sap.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class MyDataBase extends SQLiteOpenHelper {

	public static final String PHONETABLE="PhoneTable";
	public static final String DIALOG_TABLE = "MyDialogTable";
	public MyDataBase(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		String sql=" create table " + PHONETABLE + " ("
				    +"[PhoneId] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
					+ "[PhoneNumber] nvarchar(20)  NOT NULL,"
					+ "[PhonePWD] nvarchar(20), "
  					+ "[PhoneSIMCode] nvarchar(20)"
  					+ ");";
		String sqlDialog="CREATE TABLE IF NOT EXISTS "+DIALOG_TABLE+"("
				+"id		INTEGER	PRIMARY KEY  AUTOINCREMENT NOT NULL,"
				+"tell 	VARCHAR(50) 	NOT NULL " +")";
		database.execSQL(sqlDialog);
		database.execSQL(sql);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		db.execSQL("DROP TABLE IF EXISTS " + PHONETABLE);
		db.execSQL("DROP TABLE IF EXISTS " + DIALOG_TABLE);
		onCreate(db);

	}

}
